package com.zmc.order.controller;

import com.zmc.common.utils.R;
import com.zmc.order.application.OrderApplicationService;
import com.zmc.order.infrastructure.bean.query.MerchantOrderManageQuery;
import com.zmc.order.infrastructure.bean.query.OrderManageQuery;
import com.zmc.order.infrastructure.bean.vo.OrderInfoVo;
import com.zmc.order.infrastructure.service.MerchantOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;


/**
 * 商户订单
 * @author zmc
 * @date 2024-10-09 14:52:02
 */
@RestController
@RequestMapping("/merchant")
public class MerchantOrderController {

    @Autowired
    private MerchantOrderService merchantOrderService;

    @Autowired
    private OrderApplicationService orderApplicationService;

    /**
     * 后台商户订单列表 todo 待改版
     * */
    @PostMapping("/page")
    public R page(@RequestBody MerchantOrderManageQuery query) {
        /*return R.page(orderApplicationService.pageOrder(query));*/
        return null;
    }

    /**
     * 导出订单列表
     * */
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderManageQuery query) {
        /*List<OrderEntity> list = orderApplicationService.selectList(query);
        ExcelUtil<OrderEntity> util = new ExcelUtil<>(OrderEntity.class);
        util.exportExcel(response, list, "订单信息");*/
    }

    /**
     * 创建物流单
     * */
    @PostMapping("/freight/deliver")
    public R orderCreateLogistics(@RequestBody OrderInfoVo vo) {
        orderApplicationService.orderCreateLogistics(vo.getOrderSn());
        return R.ok();
    }

    /**
     * 订单确认发货
     * */
    @PostMapping("/freight/confirm/send")
    public R confirmSendGood(@RequestBody OrderInfoVo vo) {
        orderApplicationService.confirmSendGood(vo.getOrderSn());
        return R.ok();
    }

    /**
     * 订单运费查询
     * */
    @GetMapping("/freight/query/price")
    public R queryFreightPrice(@RequestBody OrderInfoVo vo) {
        return R.ok(orderApplicationService.queryFreightPrice(vo.getOrderSn()));
    }

}
